Exercise Deep Learning in Ecology
Science School on Quantitative Ecology 2025
Deep Learning in Ecology 🧠🍄
This exercise conveys the basic setup, training, validation and evaluation procedure for deep neural networks. It targets on an ecology-trained audience and therefore, may be simplifying and not always technically comprehensive. The pre-setup deep learning model was implemented with pytorch in python and uses a small data set to ensure that all participants can run the model on their own computers. The model design is simple, but enables participants to tweak essential hyperparameters and observe changes in the performance of the model. Especially the code was programmed together with ChatGPT. If participants have any questions after the course, they can seek support from ChatGPT or any other AI tool while keeping in mind to critically reflect and question AI answers.
Setting up Python on your computer and in RStudio 🐍💻
Please execute the individual steps of the checklist in the specified order to set up Python on your computer and enable its integration in RStudio and Markdown documents.
Install the current version of Python from here
Install the required Python packages using pip:
1. Open python in the terminal of either RStudio or your computer by simply executing the command python in the terminal.
2. Install pytorch for building deep learning models by running the following command pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126
3. Install matplotlib for creating plots by running the following command pip3 install matplotlib
4. Install numpy for mathematical operations by running the following command pip3 install numpy
5. Install pandas for handling data frames by running the following command pip3 install pandas
⚠️If pip wasn’t installed with Python, follow the instructions on how to install pip here.
Install the required R packages by running the following code chunk:
Then run the next code chunk too:
If you receive an error/warning message because {reticulate} cannot find your Python programme,
1. Open the terminal and run the command python -c "import sys; print(sys.version); print(sys.executable)" to get the path of your current python version.
2. Plug in the path to your python version in the following code chunk and run it.
Now you should be ready to run python and train deep learning models in RStudio using Markdown files! 🎉
The Deep Learning task and data set 🎯💾
For reasons of practicability, we want to train a simple DL model for a binary classification task that decides if a mushroom is edible or poisonous based on its morphological characteristics. Therefore, we will use a openly published data set on mushroom classification from kaggle.